<template>
  <div>
    <topBar></topBar>
    <topHeader></topHeader>
    <div>
      <div style="margin-left: 500px">
        <div style="width:80%;margin:0 auto;padding: 10px">
          <label styly="width:150px">成绩:</label>
          <el-input v-model="grade" placeholder="请输入关键字" style="width: 30%"></el-input>
        </div>
        <div style="width:80%;margin:0 auto;padding: 10px">
          <label styly="width:150px">学校:</label>
          <el-input v-model="unname" placeholder="请输入关键字" style="width: 30%"></el-input>
        </div>
        <div style="width:80%;margin:0 auto;padding: 10px">
          <label styly="width:150px">专业:</label>
          <el-input v-model="maname" placeholder="请输入关键字" style="width: 30%"></el-input>
          <el-button type="primary" style="margin-left: 5px" @click="find">查询</el-button>
        </div>
        <el-dialog
          :visible.sync="dialogVisible"
          width="30%">
          <span>预计该专业的录取分数为{{this.h2}},你的成绩录取的概率为：{{this.j}}</span>
        </el-dialog>
      </div>
      <div style="width:80%;margin:0 auto;padding: 10px">
        <label styly="width:150px">学校名称:</label>
        <el-input v-model="search" placeholder="请输入关键字" style="width: 30%"></el-input>
        <el-button type="primary" style="margin-left: 5px" @click="load">查询</el-button>
      </div>
      <el-table
        v-loading="loading"
        :data="tableData"
        border
        stripe
        style="width: 80%;margin:0 auto">
        <el-table-column
          prop="unname"
          label="学校">
        </el-table-column>
        <el-table-column
          prop="maname"
          label="专业"
          sortable
        >
        </el-table-column>
<!--        <el-table-column-->
<!--          label="描述">-->
<!--        </el-table-column>-->
      </el-table>
      <div style="margin:0 auto;padding-top: 20px;width: 80%">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="currentPage"
          :page-sizes="[5, 10, 20]"
          :page-size="pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total">
        </el-pagination>
      </div>
    </div>
      <miFooter></miFooter>
  </div>
</template>

<script>
import  request from '../utils/request'
import TopBar from './TopBar'
import TopHeader from './TopHeader'
import MiFooter from './MiFooter'
export default {
  components: {
    'topBar': TopBar,
    'topHeader': TopHeader,
    'miFooter': MiFooter
  },
  data () {
    return {
      loading: true,
      unname: '',
      total: 0,
      grade: '',
      search: '',
      maname: '',
      currentPage: 1,
      tableDate: [],
      pageSize: 10,
      h2: '',
      j: '',
      tableData: [],
      dialogVisible: false
    }
  },
  created () {
    this.load()
  },
  methods: {
    load () {
      this.loading = true
      request.get('api/Calculate', {
        params: {
          pageNum: this.currentPage,
          pageSize: this.pageSize,
          search: this.search
        }
      }).then(res => {
        this.loading = false
        this.tableData = res.data.records
        this.total = res.data.total
      })
    },
    handleCurrentChange (pageNum) {
      this.currentPage = pageNum
      this.load()
    },
    handleSizeChange (pageSize) {
      this.pageSize = pageSize
      this.load()
    },
    find () {
      this.dialogVisible = true
      request.get('api/Calculate/2', {
        params: {
          unname: this.unname,
          maname: this.maname
        }
      }).then(res => {
        this.loading = false
        // this.unname = res.data.unname
        // this.mname = res.data.mname
        //
        // this.h = res.data.max
        // this.l = res.data.mix
        // this.a = res.data.mark
        // if (this.grade > this.h){
        //   this.j=100
        // } else {
        //   this.j=0
        // }
        this.h2 = res.data[0].mark +((res.data[0].max-res.data[2].mark)+(res.data[2].mark-res.data[1].mark))/2
        this.j = (this.grade-this.h2)/(708-this.h2)

        console.log('ggggg'+this.j)
        console.log('11+' + this.h2)
        // console.log(res.data.records)
        // console.log(res.data)
      })
    }
    // calcu:function (){
    //   if(this.grade > this.h){
    //     this.seating = '100'
    //   }
    // }
  }
}
</script>

<style scoped>

</style>
